#include "StdAfx.h"
#include "UIImgSplit.h"
#include "UIRect.h"

CUIImgSplitBlock::CUIImgSplitBlock( int iLeft, int iTop, int iWidth, int iHeight, STRETCHDIR StretchType, float scale )
{
    m_pRect = new CUIRect();
    m_pRect->SetPosition( iLeft, iTop );
    m_pRect->SetSize( iWidth, iHeight );
    m_enumStretchDir = StretchType;
    m_fscale = scale;
    m_pDestRect = new CUIRect();
    m_pDestRect->SetPosition( iLeft, iTop );

    if ( StretchType == STRETCH_HORIZONTAL )
    {
        m_pDestRect->SetSize( ( int )( m_fscale * m_pRect->GetWidth() ), ( int )( m_pRect->GetHeight() ) );
    }
    else
    {
        m_pDestRect->SetSize( ( int )( m_pRect->GetWidth() ), ( int )( m_fscale * m_pRect->GetHeight() ) );
    }

}

CUIImgSplitBlock::~CUIImgSplitBlock()
{
    if ( NULL != m_pRect )
    {
        delete m_pRect;
        m_pRect = NULL;
    }
}

CUIImgSplit::CUIImgSplit( void )
{

}


CUIImgSplit::~CUIImgSplit( void )
{
    if ( !m_vecBlock.empty() )
    {
        m_vecBlock.clear();
    }
}

void CUIImgSplit::AddSplitBlock( CUIImgSplitBlock* pBlock )
{
    m_vecBlock.push_back( pBlock );
}

int CUIImgSplit::GetSplitBlockCount()const
{
    return m_vecBlock.size();
}

CUIImgSplitBlock* CUIImgSplit::GetSplitBlock( int iIndex )
{
    return m_vecBlock[iIndex];
}


